//
// Created by Administrator on 2020/7/8.
//T5章:数组、指针与字符串
//对象数组
//对象数组的定义与访问
//1.定义:类名 数组名[元素个数];
//2.访问:通过下标访问  数组名[下标].成员名


//Point.h
#ifndef _POINT_H
#define _POINT_H
class Point//类定义
{
public://外部接口
    Point();
    Point(int x,int y);
    ~Point();
    void move(int newX,int newY);
    int getX()const {return x;}
    int getY()const {return y;}
    static void showCount();//静态函数成员

private:
    int x,y;
};
#endif//_POINT_H

//Point.cpp
#include <iostream>
#include "Point.h"
using namespace std;
Point::Point():x(0),y(0) {cout<<"Default Constructor called."<<endl;}
Point::Point(int x, int y) :x(x),y(y){cout<<"Constructor called"<<endl;}
Point::~Point() {cout<<"Moving the point to ("<<newX<<","<<newY<<")"<<endl;x=newX;y=newY;}

//main.cpp
#include "Point.h"
#include <iostream>
using namespace std;
int main()
{
    cout<<"Entering main..."<<endl;
    Point a[2];//Aim a[]
    for(int i=0;i<2;i++)
        a[i].move(i+10,i+20);//Aim a[]
    cout<<"Exiting main..."<<endl;
    return 0;
}